package com.crm.customers.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.customers.dao.ArticleDao;
import com.crm.customers.model.Article;
import com.crm.sys.model.Province;

@Repository("articleDao")
public class ArticleDaoImpl extends BaseDao implements ArticleDao {
	
	private static final String MAPPER_NAMESPACE = "ArticleMapper.";

	@Override
	public List<Province> getUserProvinceNameList(Article art) {
		return selectList(MAPPER_NAMESPACE+"getUserProvinceNameList", art);
	}

	@Override
	public int savearticle(Article art) {
		return insert(MAPPER_NAMESPACE+"savearticle", art);
	}

	@Override
	public List<Article> getArticleListByParams(Article art) {
		List<Article> list = selectList(MAPPER_NAMESPACE+"getArticleListByParams", art);
		if (list != null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getArticleListCountByParams", art));
		}
		return list;
	}

	@Override
	public int deleteArticle(Article art) {
		return update(MAPPER_NAMESPACE+"deleteArticle", art);
	}

	@Override
	public int updatearticle(Article art) {
		return update(MAPPER_NAMESPACE+"updatearticle", art);
	}
	
	

}
